package com.wsx.ones.monitor.core.executer;

import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 线程池对于提交的任务无法执行和无法添加队列是执行的策略，选择的是抛弃的策略
 * Created by wangshuaixin on 17/2/6.
 */
public class RpcRejectedExecutionHandler extends ThreadPoolExecutor.AbortPolicy {

    private String threadName;
    public RpcRejectedExecutionHandler (String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
        throw new RejectedExecutionException("rpcTask " + threadName +
                " rejected from " +
                e.toString());
    }
}
